<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>

var intersection = function(nums1, nums2) {
    let map = new Map()
    nums1.forEach(item => {
        map.set(item,true)
    })
    let arr = []
    nums2.forEach(item => {
        if(map.get(item)){
            arr.push(item)
            map.delete(item)
        }
    })
    return arr
};

</script>
</body>
</html>